// From Element Plus
@use "./config" as *;
@use "./function" as *;
@use "sass:string";

$B: null;
$E: null;

/* Block 块 */
@mixin b($block) {
  $B: $namespace + $common-separator + $block !global;

  .#{$B} {
    @content;
  }
}

/* 多个 Block 块 */
@mixin multiple-b($block) {
  $B: $namespace + $common-separator !global;
  $elector: "";
  /* 拼接逗号 */
  @each $unit in $block {
    $elector: #{$elector + "." + $B + $unit + ","};
  }
  /* 去掉最后一个多余的逗号 */
  $elector: string.slice($elector, 1, -2);

  #{$elector} {
    @content;
  }
}

/* Element 元素 */
@mixin e($element) {
  $E: $element !global;
  $selector: &;
  $currentSelector: "";
  @each $unit in $element {
    $currentSelector: #{$currentSelector + "." + $B + $element-separator + $unit + ","};
  }

  @if hitAllSpecialNestRule($selector) {
    @at-root {
      #{$selector} {
        #{$currentSelector} {
          @content;
        }
      }
    }
  } @else {
    @at-root {
      #{$currentSelector} {
        @content;
      }
    }
  }
}

/*Modifier 修饰符 */
@mixin m($modifier) {
  $selector: &;
  $currentSelector: "";
  @each $unit in $modifier {
    $currentSelector: #{$currentSelector + $selector + $modifier-separator + $unit + ","};
  }

  @at-root {
    #{$currentSelector} {
      @content;
    }
  }
}

@mixin when($state) {
  @at-root {
    &.#{$state-prefix + $state} {
      @content;
    }
  }
}
